import java.io.*;
import java.util.*;

public class Main {
	BufferedReader bf;
	StringTokenizer st;
	StringBuilder output = new StringBuilder();

	double Weight;
	double[] w = new double[3];
	double[] p = new double[w.length];
	double[] lv;
	int[] no;
	
	public static void main(String[] args) {
		Main main = new Main();
		main.beginProcess();
	}
	
	public void beginProcess() {
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n, i;
		
		try {
			st = new StringTokenizer(bf.readLine());
			n = Integer.parseInt(st.nextToken());
			
			while(n != 0) {
				st = new StringTokenizer(bf.readLine());
				Weight = Double.parseDouble(st.nextToken());
				
				w = new double[3];
				p = new double[w.length];
				for(i = 0; i < w.length; i++)
					w[i] = Double.parseDouble(st.nextToken());
				for(i = 0; i < p.length; i++)
					p[i] = Double.parseDouble(st.nextToken());
				
				addResultToOutput();
				
				n--;
			}
			
			System.out.print(output);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void addResultToOutput() {
		double tmp;
		int i, j, tmpNo;
		
		lv = new double[w.length];
		no = new int[] {0, 1, 2};
		for(i = 0; i < lv.length; i++)
			lv[i] = p[i] / w[i];		
		for(i = 0; i < lv.length - 1; i++)
			for(j = 0; j < lv.length - 1 - i; j++)
				if(lv[j] > lv[j + 1]) {
					tmp = w[j];
					w[j] = w[j + 1];
					w[j + 1] = tmp;
					
					tmp = p[j];
					p[j] = p[j + 1];
					p[j + 1] = tmp;
					
					tmp = lv[j];
					lv[j] = lv[j + 1];
					lv[j + 1] = tmp;
					
					tmpNo = no[j];
					no[j] = no[j + 1];
					no[j + 1] = tmpNo;
				}

		double calorie = 0;
		String[] ate = new String[w.length];
		for(i = 0; i < w.length; i++)
			ate[i] = String.format("%.3f ", 0d);
		for(i = 0; i < w.length; i++) {
			if(Weight >= w[i]) {
				ate[no[i]] = String.format("%.3f ", w[i]);
				calorie += p[i];
				Weight -= w[i];
			} else {
				ate[no[i]] = String.format("%.3f ", Weight);
				calorie += Weight * lv[i];
				Weight = 0;
				break;
			}
		}
		
		output.append(ate[0] + ate[1] + ate[2] + String.format("%.3f%n", calorie));
	}

}